package com.xbk.seckill.stock.domain.model.entity;

import com.xbk.seckill.common.utils.id.SnowFlakeFactory;
import lombok.Data;

import java.io.Serializable;

/**
 * 商品库存分桶
 *
 * @author xiexu
 * @date 2025/3/8 21:43
 */
@Data
public class SeckillStockBucket implements Serializable {

    private static final long serialVersionUID = 6965796752002288513L;

    /**
     * 数据主键id
     */
    private Long id;

    /**
     * 商品id
     */
    private Long goodsId;

    /**
     * 当前分桶下的初始库存
     */
    private Integer initialStock;

    /**
     * 当前可用库存
     */
    private Integer availableStock;

    /**
     * 该字段用于表示库存分桶的状态
     * 0: 不可用; 1:可用
     */
    private Integer status;

    /**
     * 分桶编号
     */
    private Integer serialNo;


    public SeckillStockBucket() {
    }

    public SeckillStockBucket(Long goodsId, Integer initialStock, Integer availableStock, Integer status, Integer serialNo) {
        this.id = SnowFlakeFactory.getSnowFlakeFromCache().nextId();
        this.goodsId = goodsId;
        this.initialStock = initialStock;
        this.availableStock = availableStock;
        this.status = status;
        this.serialNo = serialNo;
    }
}
